/**
 * 
 */
package com.alstudio.ui.module.props;

import java.util.ArrayList;

import android.content.Context;
import android.os.Bundle;

import com.alstudio.app.ALLocalEnv;
import com.alstudio.module.xmpp.request.ALUiXmppRequestCreator;
import com.alstudio.pojo.ALXmppEvent;
import com.alstudio.pojo.module.local.Prop;
import com.alstudio.ui.base.TitleBarActivity;
import com.alstudio.utils.log.ALLog;
import com.alstudio.view.toast.MyToastUtil;
import com.loovee.imaohu.R;

/**
 * 我的道具
 * 
 * @author alonso lee
 * 
 */
public class MyPropsActivity extends TitleBarActivity {

	// 我的道具列表
	private ArrayList<Prop> myProps = new ArrayList<Prop>();

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.TitleBarActivity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setupView(getApplicationContext(), getClass().getSimpleName());
		requeqtData();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#setupView(android.content.Context,
	 * java.lang.String)
	 */
	@Override
	protected void setupView(Context context, String name) {
		// TODO Auto-generated method stub
		super.setupView(context, name);
		setCenterTextViewMessage(R.string.TxtMyProps);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#initData()
	 */
	@Override
	protected void initData() {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#requeqtData()
	 */
	@Override
	public void requeqtData() {
		// TODO Auto-generated method stub
		super.requeqtData();
		// 请求我的道具
		if (ALLocalEnv.isSendXmppDataEnable()) {
			ALUiXmppRequestCreator.postALUiXmppCheckUserPropsList();
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.ui.base.BaseActivity#handleGetUserPropsListEvent(com.alstudio
	 * .pojo.ALXmppEvent)
	 */
	@Override
	public void handleGetUserPropsListEvent(ALXmppEvent data) {
		// TODO Auto-generated method stub
		super.handleGetUserPropsListEvent(data);
		if(data.getResponseCode() == ALXmppEvent.RESPONSE_OK){
			ALLog.d("得到我的道具列表 ");
			@SuppressWarnings("unchecked")
			ArrayList<Prop> tmp = (ArrayList<Prop>) data.getData();
			myProps.addAll(tmp);
			tmp.clear();
			tmp = null;
			MyToastUtil.getInstance().showCenterToastOnCenter("我的道具列表个数 "+myProps.size());
		}
	}
}
